import Vue from "vue";
import VueRouter from "vue-router";

import User from "../views/User";
import SaveUser from "../views/User/SaveUser";
import UpdateUser from "../views/User/UpdateUser";

Vue.use(VueRouter);

export default new VueRouter({
  routes: [
    {
      name: "User",
      path: "/user",
      component: User,
    },
    {
      name: "SaveUser",
      path: "/user/save",
      component: SaveUser,
    },
    {
      name: "UpdateUser",
      path: "/user/update/:id", // 地址能保留id参数，组件就能通过id参数获取user数据，展示
      // path: "/user/update", // 没有id参数，一旦刷新数据就没了
      component: UpdateUser,
    },
    {
      path: "*",
      redirect: "/user",
    },
  ],
});
